﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Robotics.Race
{
    public class RoadType
    {
        public int maximumSensedValue;
        public double speedFactor;
        public double turnFactor;
        public string name;
        public override string ToString()
        {
            return name;
        }
    }

    public class RoadTypeAffector : Affector
    {
        RoadType grass = new RoadType
        {
            maximumSensedValue = 50,
            speedFactor = 0.5,
            turnFactor = 0.5,
            name = "Grass"
        };
        RoadType none = new RoadType
        {
            maximumSensedValue = 0,
            speedFactor = 0,
            turnFactor = 0,
            name = "None"
        };
        List<RoadType> roadTypes = new List<RoadType>();

        public RoadTypeAffector()
        {
            roadTypes.Add(none);
            roadTypes.Add(grass);
        }

        public RoadType GetRoadType(int value)
        {
            foreach (RoadType type in roadTypes)
            {
                if (type.maximumSensedValue < value)
                    return type;
            }
            return none;
        }

        public override void Affect(Car car, SensedEnvironment environment)
        {
            RoadType leftRoadType, rightRoadType;
            leftRoadType = GetRoadType(environment.LeftLight.Value);
            rightRoadType = GetRoadType(environment.RightLight.Value);
            if (leftRoadType == grass && rightRoadType == grass)
            {
            }
        }

        public override string ToString()
        {
            return "RoadTypeAffector";
        }
        
    }
}
